import React,{Component} from 'react';

import styles from './tabs.scss';
import CSSModules from 'react-css-modules';
import axios from 'axios';

class Weekone extends Component{
  constructor(){
    super();
    this.state={
      imgBox:[]
    }
  }
  componentDidMount(){
    this.getMovies();

  }

  getMovies=()=>{
    axios({
      method:'post',
      url:`http://47.110.60.142:8080/zhuiying/category`,
      params:{pname:'纪录片'}
    }).then(res=>{
   //  console.log(res.data);
      this.setState({
        imgBox:res.data
      });
    }).catch(err=>{
      console.log(err);
    })
  }

  getMoimg(ids){
    var jsx=[];
    var data=this.state.imgBox;

    var idd=1+801;
    //console.log(idd);
if(Number(ids)!=''){
  idd=Number(ids)+801;
  for(var i=0;i<data.length;i++){
    if(idd==data[i].id){
//console.log(idd);
     jsx.push(
           <ul styleName="help-img" key={i}>
           <li><a href="#"><img src={data[i].cimage}/></a>

           </li>
           <li><a href="#"><img src={data[i].cimage}/></a></li>
           <li><a href="#"><img src={data[i].cimage}/></a></li>
          <div styleName="clear"></div>
          </ul>

        )
        break;
    }
  }
}else{

  for(var i=0;i<data.length;i++){
    if(idd==data[i].id){
     jsx.push(
           <ul styleName="help-img" key={i}>
           <li><a href="#"><img src={data[i].cimage}/></a></li>
           <li><a href="#"><img src={data[i].cimage}/></a></li>
           <li><a href="#"><img src={data[i].cimage}/></a></li>
          <div styleName="clear"></div>
          </ul>




        )
        break;
    }
  }

}

      //console.log(data)


    return jsx;
  }

  render(){

     const id=this.props.match.params.id;


        return(

          <div>{this.getMoimg(id)}</div>

        )
     }
  }
export default CSSModules(Weekone,styles,{allowMultiple:true});
